<?php include TMPL_PATH.'public/header.phtml';?>
<div class="subnav">
    <div class="content-menu ib-a blue line-x">
    	<div style="float:left;margin-right:50px;">
        <a href='javascript:;' class="on"><em>发货单列表</em></a>
      </div>
    	<div style="color:#000;">
    		<form name="searchform" action="<?php echo U('order/order_delivery_list');?>"  method="post">
    		<input type="hidden" value="1" name="search">
    		发货单流水号<input type="text" class="input-text"  name="delivery_sn" value="<?php echo $delivery_sn ?>">
    		订单号<input type="text" class="input-text"  name="order_sn" value="<?php echo $order_sn ?>">
    		物流货号<input type="text" class="input-text"  name="shipping_no" value="<?php echo $shipping_no ?>">
    		发货单状态：<select name="status"><option value=''>≡ 全部  ≡</option>
    		<?php 
    			$statusList = OrderModel::$deliveryStatus;
    			foreach ($statusList as $key => $val):
    		?>
				<option value='<?php echo $key;?>'  <?php if($status==$key)echo 'selected';?> ><?php echo $val?></option>
				<?php endforeach;?>
				</select>
				<input type="submit" value="搜索" class="button" name="search">
    		</form>

    	</div>
    </div>
    <div style="float:right;">
         <a href="<?php echo U('order/settlementfedex');?>" target="_blank">打印FedEX报文清单</a>
    </div>
</div>
<div class="bk"></div>
<div class="pad_10">
<div class="table-list">
    <table width="100%" cellspacing="0" >
        <thead>
            <tr>
            <th width="150">发货单流水号</th>
            <th align='center' width="150">订单号</th>
            <th align='center' width="150">下单时间</th>
            <th align='left' width="150">物流号</th>
            <th align='center' width="150">发货时间</th>
            <th align='center' width="150">发货单状态</th>
            <th align='center' width="80">退税</th>            
            <th align='center' width="80">操作人</th>
			<th>管理操作</th>
            </tr>
        </thead>
    <tbody>
    <?php
   	if(isset($deliveryList) && $deliveryList):
   		foreach ($deliveryList as $v):
   ?>
			<tr>
					<td align='center'><?php echo $v['delivery_sn']?></td>
					<td align='center'><?php echo $v['order_sn'];?></td>
					<td align='center'><?php echo date('Y-m-d H:i:s', $v['start_time']);?></td>
					<td><?php echo $v['shipping_no']?></td>
                    <td align='center'><?php if($v['status'] == 2){echo date('Y-m-d H:i:s', $v['update_time']);}?></td>
					<td align='center'><?php echo OrderModel::$deliveryStatus[$v['status']];?></td>
                    <td align='center'><?php if($v['settlement'] == 1){echo '已发送';}elseif($v['settlement'] == 2){echo '已确认';}elseif($v['settlement'] == 3){echo '<span title="'.$v['settlement_info'].'&#10;-'.$v['settlement_time'].'"  style="color:#FF0000">已拒绝</span>';}?></td>                    
					<td align='center'><?php echo $v['action_user']?></td>
					<td align='center'> 
					<a href="<?php echo U('order/order_delivery_edit', array('oid' => $v['order_id'], 'did'=>$v['id']));?>">查看</a>
					 | <a href="javascript:confirmurl('<?php echo U('order/order_delivery_del', 'did='.$v['id']);?>','确认要删除 『<?php echo $v['delivery_sn']?>』 吗？')">删除</a>
					<?php if($v['status'] == 2 && ($v['settlement'] == 0 || $v['settlement'] == 3 )):?>| <a href="javascript:void(0);" onclick="settlement('<?php echo $v['order_id'] ?>', '<?php echo $v['id'] ?>')">申报退税</a><?php endif;?>
                    </td>
				</tr>
	<?php 
		endforeach;
		endif;
	?>
   </tbody>
    </table>
<div id="pages"><?php echo $pageShow;?></div>
</div>
</div>
</body>
</html>
<script type="text/javascript">
function settlement(oid,did){
	$.ajax({
		type: 'POST',
		url: "<?php echo U('order/settlement');?>",
		data: {"round":Math.random(),'order_id':oid,'did':did},
		dataType:'html',
		success: function(msg) {
			if(msg != '1'){
			    alert(msg);return;
			}
			location.reload() 
		}
	});
}
</script>